package com.droowa.domain;

import java.io.Serializable;

public class BoardList implements Serializable {
	//분류 / 게시판제목 / 게시판ID / 권한(쓰기,읽기) / 새글,전체글 / 관리 / 공개여부
	String boardClass;
	String boardTitle;
	int boardId;
	String wPermission;
	String rPermission;
	int newPaper;
	int allPaper;
	String url;
	String open;
	
	public BoardList() {
		super();
	}

	public BoardList(String boardClass, String boardTitle, int boardId,
			String wPermission, String rPermission, int newPaper, int allPaper,
			String url, String open) {
		super();
		this.boardClass = boardClass;
		this.boardTitle = boardTitle;
		this.boardId = boardId;
		this.wPermission = wPermission;
		this.rPermission = rPermission;
		this.newPaper = newPaper;
		this.allPaper = allPaper;
		this.url = url;
		this.open = open;
	}

	public String getBoardClass() {
		return boardClass;
	}

	public void setBoardClass(String boardClass) {
		this.boardClass = boardClass;
	}

	public String getBoardTitle() {
		return boardTitle;
	}

	public void setBoardTitle(String boardTitle) {
		this.boardTitle = boardTitle;
	}

	public int getBoardId() {
		return boardId;
	}

	public void setBoardId(int boardId) {
		this.boardId = boardId;
	}

	public String getwPermission() {
		return wPermission;
	}

	public void setwPermission(String wPermission) {
		this.wPermission = setPermission(wPermission);
	}

	public String getrPermission() {
		return rPermission;
	}

	public void setrPermission(String rPermission) {
		this.rPermission = setPermission(rPermission);
	}

	public int getNewPaper() {
		return newPaper;
	}

	public void setNewPaper(int newPaper) {
		this.newPaper = newPaper;
	}

	public int getAllPaper() {
		return allPaper;
	}

	public void setAllPaper(int allPaper) {
		this.allPaper = allPaper;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getOpen() {
		return open;
	}

	public void setOpen(String open) {
		if(open.equals("1")) {
			this.open = "공개";
		} else {
			this.open = "비공개";
		}
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + allPaper;
		result = prime * result
				+ ((boardClass == null) ? 0 : boardClass.hashCode());
		result = prime * result + boardId;
		result = prime * result
				+ ((boardTitle == null) ? 0 : boardTitle.hashCode());
		result = prime * result + newPaper;
		result = prime * result + ((open == null) ? 0 : open.hashCode());
		result = prime * result
				+ ((rPermission == null) ? 0 : rPermission.hashCode());
		result = prime * result + ((url == null) ? 0 : url.hashCode());
		result = prime * result
				+ ((wPermission == null) ? 0 : wPermission.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BoardList other = (BoardList) obj;
		if (allPaper != other.allPaper)
			return false;
		if (boardClass == null) {
			if (other.boardClass != null)
				return false;
		} else if (!boardClass.equals(other.boardClass))
			return false;
		if (boardId != other.boardId)
			return false;
		if (boardTitle == null) {
			if (other.boardTitle != null)
				return false;
		} else if (!boardTitle.equals(other.boardTitle))
			return false;
		if (newPaper != other.newPaper)
			return false;
		if (open == null) {
			if (other.open != null)
				return false;
		} else if (!open.equals(other.open))
			return false;
		if (rPermission == null) {
			if (other.rPermission != null)
				return false;
		} else if (!rPermission.equals(other.rPermission))
			return false;
		if (url == null) {
			if (other.url != null)
				return false;
		} else if (!url.equals(other.url))
			return false;
		if (wPermission == null) {
			if (other.wPermission != null)
				return false;
		} else if (!wPermission.equals(other.wPermission))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "BoardList [boardClass=" + boardClass + ", boardTitle="
				+ boardTitle + ", boardId=" + boardId + ", wPermission="
				+ wPermission + ", rPermission=" + rPermission + ", newPaper="
				+ newPaper + ", allPaper=" + allPaper + ", url=" + url
				+ ", open=" + open + "]";
	}
	
	private String setPermission(String permission) {
		String result = null;
		if(Integer.parseInt(permission) == 1) {
			result = "관리자";
		} else if(Integer.parseInt(permission) == 2) {
			result = "회원이상";
		} else {
			result = "전체";
		}
		return result;
	}
}
